home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 1992 August
/
info-mac-1992.iso
/
Applications (app)
/
Image 1.44
/
Macros
/
LUT Macros
< prev
next >
Wrap
Text File
|
1991-12-16
|
5KB
|
269 lines
macro 'Export LUT [E]';
{
Copies the current look-up table to the Area(Red), Mean(Green) and
Perimeter/Length(blue) columns. Use the Export command to copy
it to a tab-delimeted text file. Max Measurements must be set to
256 or greater.
}
var
i:integer;
v:real;
begin
SetCounter(256); {SetCounter new in V1.41}
MeasureArea(true);
MeasureDensity(true);
MeasurePerimeter(true);
for i:=0 to 255 do begin
rArea[i+1]:=RedLut[i];
rMean[i+1]:=GreenLut[i];
rLength[i+1]:=BlueLut[i];
end;
ShowResults;
{Export;}
end;
macro 'Invert LUT [I]';
var
i:integer;
begin
for i:=0 to 255 do begin
RedLUT[i]:=255-RedLut[i];
GreenLUT[i]:=255-GreenLut[i];
BlueLUT[i]:=255-BlueLut[i];
if (i mod 10)=0 then UpdateLUT;
end;
UpdateLUT;
end;
macro 'Random Colors [C]';
var
i,colors,entries,first,last,r,g,b:integer;
begin
colors:=25;;
entries:=256/colors;
if entries>256 then entries:=256;
repeat
first:=random*255;
last:=first+entries-1;
if last>255 then last:=255;
r:=random*255;
g:=random*255;
b:=random*255;
for i:=first to last do begin
RedLUT[i]:=r;
GreenLUT[i]:=g;
BlueLUT[i]:=b;
end;
UpdateLUT;
until button;
end;
macro 'Log Tranform';
var
i,v:integer;
ln255:real;
BEGIN
RedLUT[255]:=0;
GreenLUT[255]:=0;
BlueLUT[255]:=0;
ln255:=ln(255);
for i:=1 to 255 DO begin
v:=round(ln(i)*255.0/ln255);
RedLUT[255-i]:=v;
GreenLUT[255-i]:=v;
BlueLUT[255-i]:=v;
end;
UpdateLUT;
END.
macro 'Square Tranform';
var
i,v:integer;
sqr255:real;
BEGIN
sqr255:=sqr(255.0);
for i:=1 to 255 DO begin
v:=round(sqr(i)*255.0/sqr255);
RedLUT[255-i]:=v;
GreenLUT[255-i]:=v;
BlueLUT[255-i]:=v;
end;
UpdateLUT;
END.
macro 'Square Root Tranform';
var
i,v:integer;
sqrt255:real;
BEGIN
sqrt255:=sqrt(255.0);
for i:=1 to 255 DO begin
v:=round(sqrt(i)*255.0/sqrt255);
RedLUT[255-i]:=v;
GreenLUT[255-i]:=v;
BlueLUT[255-i]:=v;
end;
UpdateLUT;
END.
macro 'Reset LUT [R]';
begin
ResetGrayMap;
end;
macro 'Plot LUT [P]';
var
i,xscale,yscale:real;
width,height,margin,pwidth,pheight:integer;
xbase,ybase:integer;
begin
SaveState;
margin:=25;
pwidth:=400;
pheight:=125;
width:=pwidth+2*margin;
height:=pheight*3+2*margin;
SetNewSize(width,height);
SetBackground(0);
MakeNewWindow('LUT');
xscale:=(pwidth-2)/256;
yscale:=(pheight-1)/256;
SetForeground(252);
xbase:=margin; ybase:=margin;
MoveTo(xbase,ybase);
for i:=0 to 255 do
LineTo(xbase+i*xscale,ybase+RedLUT[i]*yscale);
SetForeground(255);
MakeRoi(xbase,ybase,pwidth,pheight);
FlipVertical;
DrawBoundary;
SetForeground(253);
ybase:=ybase+pheight-1;
MoveTo(xbase,ybase);
for i:=0 to 255 do
LineTo(xbase+i*xscale,ybase+GreenLUT[i]*yscale);
SetForeground(255);
MakeRoi(xbase,ybase,pwidth,pheight);
FlipVertical;
DrawBoundary;
SetForeground(254);
ybase:=ybase+pheight-1;
MoveTo(xbase,ybase);
for i:=0 to 255 do
LineTo(xbase+i*xscale,ybase+BlueLUT[i]*yscale);
SetForeground(255);
MakeRoi(xbase,ybase,pwidth,pheight);
FlipVertical;
DrawBoundary;
KillRoi;
RedLUT[252]:=255; GreenLUT[252]:=0; BlueLUT[252]:=0;
RedLUT[253]:=0; GreenLUT[253]:=255; BlueLUT[253]:=0;
RedLUT[254]:=0; GreenLUT[254]:=0; BlueLUT[254]:=255;
UpdateLUT;
SetFont('Geneva');
SetFontSize(9);
SetText('Centered');
MoveTo(margin+4,height-margin+8);
writeln(0:1:2);
MoveTo(margin+pwidth,height-margin+8);
writeln(255:1:2);
RestoreState;
end;
macro 'Show RGB Values [S]';
var
x,y,v,savex,savey:integer;
begin
repeat
savex:=x; savey:=y;
GetMouse(x,y);
if (x<>savex) or (y<>savey) then begin
v:=GetPixel(x,y);
ShowMessage('loc=',x:1,', ',y:1,
'\value=',v:1,
'\RGB=',RedLUT[v]:1,', ',GreenLUT[v]:1,', ',BlueLUT[v]:1);
wait(.5);
end;
until button;
end;
macro 'Posterize';
var
level,i:integer
delta,steps,StepSize,NextStep:real;
begin
steps:=GetNumber('Number of Gray Steps(2-256):',8);
StepSize:=256/steps;
delta:=256/(steps-1);
NextStep:=trunc(StepSize);
level:=255;
for i:=0 to 255 do begin
if i>=NextStep then begin
NextStep:=trunc(NextStep+StepSize);
level:=level-delta;
UpdateLUT;
end;
if level<0 then level:=0;
RedLUT[i]:=level;
GreenLUT[i]:=level;
BlueLUT[i]:=level;
end;
end;
macro 'Make Four Ramp LUT';
var
i,entry:integer;
BEGIN
entry:=0;
for i:=0 to 63 DO begin
RedLUT[entry]:=255-i*4;
GreenLUT[entry]:=255-i*4;
BlueLUT[entry]:=255-i*4;
entry:=entry+1;
end;
for i:=0 to 63 DO begin
RedLUT[entry]:=255-i*4;
GreenLUT[entry]:=0;
BlueLUT[entry]:=0;
entry:=entry+1;
end;
for i:=0 to 63 DO begin
RedLUT[entry]:=0;
GreenLUT[entry]:=255-i*4;
BlueLUT[entry]:=0;
entry:=entry+1;
end;
for i:=0 to 63 DO begin
RedLUT[entry]:=0;
GreenLUT[entry]:=0;
BlueLUT[entry]:=255-i*4;
entry:=entry+1;
end;
UpdateLUT;
END.
macro 'Make Composite Image'
begin
SelectSlice(1);
MultiplyByConstant(0.248);
AddConstant(64);
SelectSlice(2);
MultiplyByConstant(0.248);
AddConstant(128);
SelectSlice(3);
MultiplyByConstant(0.248);
AddConstant(192);
end;